<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            padding: 0;
            margin: 0;
        }

        .countTime {
            font-size: 32px;
            font-family: "clockIcon";
            padding: 10px 20px;
        }

        .milli {
            font-size: 20px;
        }

        .buttonGroup {
            padding: 5px 20px;
        }
    </style>
</head>

<body>
    <div class="countTime">
        <span class="minute">00</span>:<span class="second">00</span>.<span class="milli">00</span>
    </div>
    <div class="buttonGroup">
        <button class="start">开始</button>
        <button class="pause">暂停</button>
        <button class="reset">重置</button>
    </div>
</body>
<script>
    var minuteSpan = document.getElementsByClassName("minute")[0];
    var secondSpan = document.getElementsByClassName("second")[0];
    var milliSpan = document.getElementsByClassName("milli")[0];
    var start = document.getElementsByClassName("start")[0];
    var pause = document.getElementsByClassName("pause")[0];
    var reset = document.getElementsByClassName("reset")[0];

    var ms = 0;
    var timer = null;
    function beauty(num) {
        return num < 10 ? "0" + num : num;
    }
    start.onclick = function () {
        clearInterval(timer);
        timer = setInterval(function () {
            ms += 10;
            var milli = ms % 1000 / 10;
            var second = parseInt(ms / 1000 % 60);
            var minute = parseInt(ms / 1000 / 60 % 60);

            minuteSpan.innerText = beauty(minute);
            secondSpan.innerText = beauty(second);
            milliSpan.innerText = beauty(milli);
        }, 10)
    }
    pause.onclick = function () {
        clearInterval(timer);
    }
    reset.onclick = function () {
        clearInterval(timer);
        minuteSpan.innerText = beauty(0);
        secondSpan.innerText = beauty(0);
        milliSpan.innerText = beauty(0);
    }
</script>

</html>